package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import com.qf.service.DtsPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class DtsPermissionServiceImpl implements DtsPermissionService {

    @Autowired
    private DtsPermissionMapper dtsPermissionMapper;
    @Override
    public Set<String> findPermsByRoleIds(Integer[] roleIds) {
        List<DtsPermission> dtsPermissionList = dtsPermissionMapper.selectList(new LambdaQueryWrapper<DtsPermission>()
        .select(DtsPermission::getPermission).in(DtsPermission::getRoleId,roleIds).eq(DtsPermission::getDeleted,false));
        Set<String> dtsPermissions = dtsPermissionList.stream().map(DtsPermission::getPermission).collect(Collectors.toSet());
        return dtsPermissions;
    }
}
